<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // slice
      function reverse(str = "") {
        const len = str.length;
        let newStr = "";
        for (let i = len - 1; i >= 0; i--) {
          newStr += str[i];
        }
        return newStr;
      }
      console.log(reverse("abcd")); // dcba
    </script>
  </body>
</html>
